package sample.controllers;

import java.awt.*;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import sample.utils.MatrixUtils;

public class Controller1stPage {
    public static int rows = 0, columns = 0;
    int flag = 0, i = 0, j = 0;

    @FXML
    private TextField numOfRows;

    @FXML
    private TextField numOfColumns;

    @FXML
    private Button genMatrix;

    @FXML
    void initialize() {
        genMatrix.setOnAction(event -> {
            System.out.println("Se genereaza matricea");
            int numberOfRows = Integer.parseInt(numOfRows.getText());
            int numberOfColumns = Integer.parseInt(numOfColumns.getText());
            generateMatrix(numberOfRows, numberOfColumns);
        });
    }

    public void generateMatrix(final int r, final int c) {
        Pane root = new Pane();
        Pane panel1 = new Pane();
        TextField[][] textMatrixArray = new TextField[30][30];
        Pane panel2 = new Pane();
        TextField[] textProbabilityArray = new TextField[30];
        Pane panel3 = new Pane();
        TextField[] text_priorityArray = new TextField[30];


        double matrix[][] = new double[30][30];
        double probabilityArray[] = new double[30];
        double priorityArray[] = new double[30];
        final double alphaArray[] = new double[30];

        String[] priorityString = new String[30];
        //Criterii
        //        ///////////////////////////////////////////////////////////CLASA I Probleme
        Text text = new Text();
        text.setFont(Font.font("noto-sans", FontWeight.BOLD, FontPosture.REGULAR, 13));
        text.setX(30);
        text.setY(20);
        text.setLayoutX(1100.0D);
        text.setLayoutX(720.0D);
        text.setText("Clasa I Prob. dec. monocrit. in conditii de incertitudine");
        text.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(text);

        Separator separator = new Separator(Orientation.HORIZONTAL);
        separator.setMinWidth(400);
        separator.setLayoutX(750.0D);
        separator.setLayoutY(22.0D);
        separator.setStyle("-fx-border-color: green");
        root.getChildren().add(separator);
////////////////////////////////////////////////////////////////////////Optimist
        // Butoanele, text fieldul si calculul la MAXIMAX
        Button calcOptimist = new Button();
        calcOptimist.setText("Calc");
        calcOptimist.setLayoutX(750.0D);
        calcOptimist.setLayoutY(30.0D);
        calcOptimist.setPrefHeight(25.0D);
        calcOptimist.setPrefWidth(56.0D);
        calcOptimist.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcOptimist.setTextFill(Color.RED);
        root.getChildren().add(calcOptimist);

        Text textOptimist = new Text();
        textOptimist.setFont(Font.font("noto-sans", FontPosture.REGULAR, 13));
        textOptimist.setX(30);
        textOptimist.setY(46);
        textOptimist.setLayoutX(750.0D);
        textOptimist.setLayoutX(777.0D);
        textOptimist.setText("Criteriul optimist (Maximax) ");
        textOptimist.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textOptimist);

        calcOptimist.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            double optimist = MatrixUtils.getOptimist(matrix, r, c);

            TextField displayOptimist = new TextField("" + optimist);
            displayOptimist.setLayoutX(1075.0D);
            displayOptimist.setLayoutY(29);
            displayOptimist.setPrefWidth(75.0D);
            displayOptimist.setPrefHeight(25.0D);
            displayOptimist.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayOptimist);
        });
//////////////////////////////////////////////////////////////////////Pesimist
        // Pessimist Buttons and text fields
        Button calcPesimist = new Button();
        calcPesimist.setText("Calc");
        calcPesimist.setLayoutX(750.0D);
        calcPesimist.setLayoutY(56.0D);
        calcPesimist.setPrefHeight(25.0D);
        calcPesimist.setPrefWidth(56.0D);
        calcPesimist.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcPesimist.setTextFill(Color.RED);
        root.getChildren().add(calcPesimist);

        Text textPesimist = new Text();
        textPesimist.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textPesimist.setX(30);
        textPesimist.setY(74);
        textPesimist.setLayoutX(750.0D);
        textPesimist.setLayoutX(777.0D);
        textPesimist.setText("Criteriul pesimist (Maximin)");
        textPesimist.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textPesimist);

        calcPesimist.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            double pesimist = MatrixUtils.getPessimist(matrix, r, c);

            TextField displayPesimist = new TextField("" + pesimist);
            displayPesimist.setLayoutX(1075.0D);
            displayPesimist.setLayoutY(55);
            displayPesimist.setPrefWidth(75.0D);
            displayPesimist.setPrefHeight(25.0D);
            displayPesimist.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayPesimist);
        });
//////////////////////////////////////////////////////////////////////////Realism
        // Butoanele, text fieldul si calculul la REALISM
        Button calcRealist = new Button();
        calcRealist.setText("Calc");
        calcRealist.setLayoutX(750.0D);
        calcRealist.setLayoutY(82.0D);
        calcRealist.setPrefHeight(25.0D);
        calcRealist.setPrefWidth(56.0D);
        calcRealist.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRealist.setTextFill(Color.RED);
        root.getChildren().add(calcRealist);

        Text textRealist = new Text();
        textRealist.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textRealist.setX(30);
        textRealist.setY(100);
        textRealist.setLayoutX(750.0D);
        textRealist.setLayoutX(777.0D);
        textRealist.setText("Criteriul realismului (Hurwiez)");
        textRealist.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textRealist);

        TextField alphaRealism = new TextField("");
        alphaRealism.setPromptText("alpha");
        alphaRealism.setLayoutX(1029.0D);
        alphaRealism.setLayoutY(81);
        alphaRealism.setPrefWidth(45.0D);
        alphaRealism.setPrefHeight(25.0D);
        alphaRealism.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
        root.getChildren().add(alphaRealism);

        calcRealist.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            alphaArray[0] = Double.parseDouble(alphaRealism.getText());
            System.out.println(alphaRealism + " ");
            double realist = MatrixUtils.getRealist(matrix, r, c, alphaArray[0]);

            TextField displayRealist = new TextField("" + realist);
            displayRealist.setLayoutX(1075.0D);
            displayRealist.setLayoutY(81);
            displayRealist.setPrefWidth(75.0D);
            displayRealist.setPrefHeight(25.0D);
            displayRealist.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRealist);
        });
/////////////////////////////////////////////////////////////////////////Echiprob
        Button calcEchiprob = new Button();
        calcEchiprob.setText("Calc");
        calcEchiprob.setLayoutX(750.0D);
        calcEchiprob.setLayoutY(108.0D);
        calcEchiprob.setPrefHeight(25.0D);
        calcEchiprob.setPrefWidth(56.0D);
        calcEchiprob.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcEchiprob.setTextFill(Color.RED);
        root.getChildren().add(calcEchiprob);

        Text textEchiprob = new Text();
        textEchiprob.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textEchiprob.setX(30);
        textEchiprob.setY(128);
        textEchiprob.setLayoutX(750.0D);
        textEchiprob.setLayoutX(777.0D);
        textEchiprob.setText("Criteriul echiprobabilităţii (Laplace)");
        textEchiprob.setFill(Color.LIGHTSKYBLUE);

        root.getChildren().add(textEchiprob);
        calcEchiprob.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            double echiprob = MatrixUtils.getEchiprob(matrix, r, c);

            TextField displayEchiprob = new TextField("" + echiprob);
            displayEchiprob.setLayoutX(1075.0D);
            displayEchiprob.setLayoutY(107);
            displayEchiprob.setPrefWidth(75.0D);
            displayEchiprob.setPrefHeight(25.0D);
            displayEchiprob.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayEchiprob);
        });
//        /////////////////////////////////////////////////////////////////////Regret
        Button calcRegret = new Button();
        calcRegret.setText("Calc");
        calcRegret.setLayoutX(750.0D);
        calcRegret.setLayoutY(134.0D);
        calcRegret.setPrefHeight(25.0D);
        calcRegret.setPrefWidth(56.0D);
        calcRegret.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRegret.setTextFill(Color.RED);
        root.getChildren().add(calcRegret);

        Text textSavage = new Text();
        textSavage.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textSavage.setX(30);
        textSavage.setY(152);
        textSavage.setLayoutX(750.0D);
        textSavage.setLayoutX(777.0D);
        textSavage.setText("Criteriul regretelor (Savage)");
        textSavage.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textSavage);

        calcRegret.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            double regret = MatrixUtils.getRegret(matrix, r, c);

            TextField displayRegret = new TextField("" + regret);
            displayRegret.setLayoutX(1075.0D);
            displayRegret.setLayoutY(133);
            displayRegret.setPrefWidth(75.0D);
            displayRegret.setPrefHeight(25.0D);
            displayRegret.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRegret);
        });
//        ///////////////////////////////////////////////////////////CLASA II Probleme
        Text text1 = new Text();
        text1.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 13));
        text1.setX(30);
        text1.setY(180);
        text1.setLayoutX(1100.0D);
        text1.setLayoutX(720.0D);
        text1.setText("Clasa II Prob. dec. monocrit. in conditii de risc");
        text1.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(text1);

        Separator separator1 = new Separator(Orientation.HORIZONTAL);
        separator1.setMinWidth(400);
        separator1.setLayoutX(750.0D);
        separator1.setLayoutY(182.0D);
        separator1.setStyle("-fx-border-color: green");
        root.getChildren().add(separator1);
//        ///////////////////////////////////////////////////////////Bayes
        // Butoanele, text fieldul si calculul la BAYES
        Button calcBayes = new Button();
        calcBayes.setText("Calc");
        calcBayes.setLayoutX(750.0D);
        calcBayes.setLayoutY(190.0D);
        calcBayes.setPrefHeight(25.0D);
        calcBayes.setPrefWidth(56.0D);
        calcBayes.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcBayes.setTextFill(Color.RED);
        root.getChildren().add(calcBayes);

        Text textBayes = new Text();
        textBayes.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textBayes.setX(30);
        textBayes.setY(208);
        textBayes.setLayoutX(750.0D);
        textBayes.setLayoutX(777.0D);
        textBayes.setText("Criteriul valorii de expectanţă (Bayes)");
        textBayes.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textBayes);

        calcBayes.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            parsePonderi(c, textProbabilityArray, probabilityArray);
            double bayes = MatrixUtils.getBayes(matrix, probabilityArray, r, c);

            TextField displayBayes = new TextField("" + bayes);
            displayBayes.setLayoutX(1075.0D);
            displayBayes.setLayoutY(190);
            displayBayes.setPrefWidth(75.0D);
            displayBayes.setPrefHeight(25.0D);
            displayBayes.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayBayes);
        });
//        ////////////////////////////////////////////////////////////////////Bernoulli
        // Butoanele, text fieldul si calculul la Rationalitatii
        Button calcBernoulli = new Button();
        calcBernoulli.setText("Calc");
        calcBernoulli.setLayoutX(750.0D);
        calcBernoulli.setLayoutY(216.0D);
        calcBernoulli.setPrefHeight(25.0D);
        calcBernoulli.setPrefWidth(56.0D);
        calcBernoulli.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcBernoulli.setTextFill(Color.RED);
        root.getChildren().add(calcBernoulli);

        Text textBernoulli = new Text();
        textBernoulli.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textBernoulli.setX(30);
        textBernoulli.setY(234);
        textBernoulli.setLayoutX(750.0D);
        textBernoulli.setLayoutX(777.0D);
        textBernoulli.setText("Criteriul raționalității(Bernoulli)");
        textBernoulli.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textBernoulli);

        calcBernoulli.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            double bernoulli = MatrixUtils.getBernoulli(matrix, r, c);

            TextField displayBernoulli = new TextField("" + bernoulli);
            displayBernoulli.setLayoutX(1075.0D);
            displayBernoulli.setLayoutY(216);
            displayBernoulli.setPrefWidth(75.0D);
            displayBernoulli.setPrefHeight(25.0D);
            displayBernoulli.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayBernoulli);
        });
        //        ///////////////////////////////////////////////////////////CLASA III Probleme
//        //////////////////////////////////////////////////////////////////Aditiva

        Text text2 = new Text();
        text2.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 13));
        text2.setX(30);
        text2.setY(260);
        text2.setLayoutX(1100.0D);
        text2.setLayoutX(720.0D);
        text2.setText("Clasa III Prob. dec. multicrit. in conditii de certitudine");
        text2.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(text2);

        Separator separator2 = new Separator(Orientation.HORIZONTAL);
        separator2.setMinWidth(400);
        separator2.setLayoutX(750.0D);
        separator2.setLayoutY(262.0D);
        separator2.setStyle("-fx-border-color: green");
        root.getChildren().add(separator2);

        // Butoanele, text fieldul si calculul la Aditiva
        Button calcAditiv = new Button();
        calcAditiv.setText("Calc");
        calcAditiv.setLayoutX(750.0D);
        calcAditiv.setLayoutY(270.0D);
        calcAditiv.setPrefHeight(25.0D);
        calcAditiv.setPrefWidth(56.0D);
        calcAditiv.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcAditiv.setTextFill(Color.RED);
        root.getChildren().add(calcAditiv);

        Text textAditiv = new Text();
        textAditiv.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textAditiv.setX(30);
        textAditiv.setY(288);
        textAditiv.setLayoutX(750.0D);
        textAditiv.setLayoutX(777.0D);
        textAditiv.setText("Metoda Aditivă");
        textAditiv.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textAditiv);

        calcAditiv.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            double aditiv = MatrixUtils.getAditive(matrix, priorityArray, r, c);

            TextField displayAditiv = new TextField("" + aditiv);
            displayAditiv.setLayoutX(1075.0D);
            displayAditiv.setLayoutY(270);
            displayAditiv.setPrefWidth(75.0D);
            displayAditiv.setPrefHeight(25.0D);
            displayAditiv.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayAditiv);
        });
//        ////////////////////////////////////////////////////////////////////////////Global Utility
        Button calcGlobalUtility = new Button();
        calcGlobalUtility.setText("Calc");
        calcGlobalUtility.setLayoutX(750.0D);
        calcGlobalUtility.setLayoutY(296.0D);
        calcGlobalUtility.setPrefHeight(25.0D);
        calcGlobalUtility.setPrefWidth(56.0D);
        calcGlobalUtility.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcGlobalUtility.setTextFill(Color.RED);
        root.getChildren().add(calcGlobalUtility);

        Text textGlobalUtility = new Text();
        textGlobalUtility.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textGlobalUtility.setX(30);
        textGlobalUtility.setY(315);
        textGlobalUtility.setLayoutX(750.0D);
        textGlobalUtility.setLayoutX(777.0D);
        textGlobalUtility.setText("Metoda utilității globale");
        textGlobalUtility.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textGlobalUtility);

        calcGlobalUtility.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            parsePonderi(c, textProbabilityArray, probabilityArray);
            priorityParse(c, text_priorityArray, priorityString);
            double globalUtility = MatrixUtils.getGlobalUtility(matrix, r, c, priorityArray, probabilityArray);

            TextField displayGlobalUtility = new TextField("" + globalUtility);
            displayGlobalUtility.setLayoutX(1075.0D);
            displayGlobalUtility.setLayoutY(296);
            displayGlobalUtility.setPrefWidth(75.0D);
            displayGlobalUtility.setPrefHeight(25.0D);
            displayGlobalUtility.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayGlobalUtility);
        });

        //        ///////////////////////////////////////////////////////////CLASA IV Probleme
//Nume clasa 4 si separator
        Text text3 = new Text();
        text3.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 13));
        text3.setX(30);
        text3.setY(340);
        text3.setLayoutX(1100.0D);
        text3.setLayoutX(720.0D);
        text3.setText("Clasa IV Prob. dec. multicrit. conditiile de incertitudine");
        text3.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(text3);

        Separator separator3 = new Separator(Orientation.HORIZONTAL);
        separator3.setMinWidth(400);
        separator3.setLayoutX(750.0D);
        separator3.setLayoutY(341.0D);
        separator3.setStyle("-fx-border-color: green");
        root.getChildren().add(separator3);

        Separator separator4 = new Separator(Orientation.VERTICAL);
        separator4.setMinHeight(608);
        separator4.setLayoutX(740.0D);
        separator4.setLayoutY(29.0D);
        separator4.setStyle("-fx-border-color: green");
        separator4.setStyle("-fx-background-color: #00ff24");
        root.getChildren().add(separator4);

        Separator separator5 = new Separator(Orientation.VERTICAL);
        separator5.setMinHeight(608);
        separator5.setLayoutX(1156.0D);
        separator5.setLayoutY(29.0D);
        separator5.setStyle("-fx-border-color: green");
        separator5.setStyle("-fx-background-color: #00ff24");
        root.getChildren().add(separator5);

        Separator separator6 = new Separator(Orientation.HORIZONTAL);
        separator6.setMinWidth(400);
        separator6.setLayoutX(750.0D);
        separator6.setLayoutY(498.0D);
        separator6.setStyle("-fx-border-color: green");
        root.getChildren().add(separator6);

        Separator separator7 = new Separator(Orientation.HORIZONTAL);
        separator7.setMinWidth(400);
        separator7.setLayoutX(750.0D);
        separator7.setLayoutY(639.0D);
        separator7.setStyle("-fx-border-color: green");
        root.getChildren().add(separator7);
// //////////////////////////////////////////////////////////////////////////////Optimist L4
        Button calcOptimistL4 = new Button();
        calcOptimistL4.setText("Calc");
        calcOptimistL4.setLayoutX(750.0D);
        calcOptimistL4.setLayoutY(349.0D);
        calcOptimistL4.setPrefHeight(25.0D);
        calcOptimistL4.setPrefWidth(56.0D);
        calcOptimistL4.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcOptimistL4.setTextFill(Color.RED);
        root.getChildren().add(calcOptimistL4);

        Text textOptimistL4 = new Text();
        textOptimistL4.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textOptimistL4.setX(30);
        textOptimistL4.setY(367);
        textOptimistL4.setLayoutX(750.0D);
        textOptimistL4.setLayoutX(777.0D);
        textOptimistL4.setText("Criteriul optimist (Maximax) ");
        textOptimistL4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textOptimistL4);

        calcOptimistL4.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            double[][] utilityMatrix = new double[r][c];
            utilityMatrix = MatrixUtils.getUtility(matrix, r, c, priorityArray);
            double optimistL4 = MatrixUtils.getOptimist(utilityMatrix, r, c);

            TextField dislpayOptimistL4 = new TextField("" + optimistL4);
            dislpayOptimistL4.setLayoutX(1075.0D);
            dislpayOptimistL4.setLayoutY(349);
            dislpayOptimistL4.setPrefWidth(75.0D);
            dislpayOptimistL4.setPrefHeight(25.0D);
            dislpayOptimistL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(dislpayOptimistL4);
        });
//        ////////////////////////////////////////////////////////////////////////////Pesimist L4
        Button calcPesimistL4 = new Button();
        calcPesimistL4.setText("Calc");
        calcPesimistL4.setLayoutX(750.0D);
        calcPesimistL4.setLayoutY(375.0D);
        calcPesimistL4.setPrefHeight(25.0D);
        calcPesimistL4.setPrefWidth(56.0D);
        calcPesimistL4.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcPesimistL4.setTextFill(Color.RED);
        root.getChildren().add(calcPesimistL4);

        Text textPesimistL4 = new Text();
        textPesimistL4.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textPesimistL4.setX(30);
        textPesimistL4.setY(394);
        textPesimistL4.setLayoutX(750.0D);
        textPesimistL4.setLayoutX(777.0D);
        textPesimistL4.setText("Criteriul pesimist (Maximin)");
        textPesimistL4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textPesimistL4);

        calcPesimistL4.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            double[][] utilityMatrix = new double[r][c];
            utilityMatrix = MatrixUtils.getUtility(matrix, r, c, priorityArray);
            double pesimistL4 = MatrixUtils.getPessimist(utilityMatrix, r, c);

            TextField displayPesimistL4 = new TextField("" + pesimistL4);
            displayPesimistL4.setLayoutX(1075.0D);
            displayPesimistL4.setLayoutY(375);
            displayPesimistL4.setPrefWidth(75.0D);
            displayPesimistL4.setPrefHeight(25.0D);
            displayPesimistL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayPesimistL4);
        });
//        /////////////////////////////////////////////////////////////////////////////Realist L4
        Button calcRealismL4 = new Button();
        calcRealismL4.setText("Calc");
        calcRealismL4.setLayoutX(750.0D);
        calcRealismL4.setLayoutY(401.0D);
        calcRealismL4.setPrefHeight(25.0D);
        calcRealismL4.setPrefWidth(56.0D);
        calcRealismL4.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRealismL4.setTextFill(Color.RED);
        root.getChildren().add(calcRealismL4);

        Text textRealismL4 = new Text();
        textRealismL4.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textRealismL4.setX(30);
        textRealismL4.setY(420);
        textRealismL4.setLayoutX(750.0D);
        textRealismL4.setLayoutX(777.0D);
        textRealismL4.setText("Criteriul realismului (Hurwiez)");
        textRealismL4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textRealismL4);

        TextField alphaRealismL4 = new TextField("");
        alphaRealismL4.setPromptText("alpha");
        alphaRealismL4.setLayoutX(1029.0D);
        alphaRealismL4.setLayoutY(401);
        alphaRealismL4.setPrefWidth(45.0D);
        alphaRealismL4.setPrefHeight(25.0D);
        alphaRealismL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
        root.getChildren().add(alphaRealismL4);

        calcRealismL4.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            parsePonderi(c, textProbabilityArray, probabilityArray);
            double[][] utilityMatrix = new double[r][c];
            utilityMatrix = MatrixUtils.getUtility(matrix, r, c, priorityArray);
            double realistL4 = MatrixUtils.getRealist(utilityMatrix, r, c, alphaArray[0]);

            TextField displayRealistL4 = new TextField("" + realistL4);
            displayRealistL4.setLayoutX(1075.0D);
            displayRealistL4.setLayoutY(401);
            displayRealistL4.setPrefWidth(75.0D);
            displayRealistL4.setPrefHeight(25.0D);
            displayRealistL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRealistL4);
        });
//        ///////////////////////////////////////////////////////////////////////Echiprob L4
        Button calcEchiprobL4 = new Button();
        calcEchiprobL4.setText("Calc");
        calcEchiprobL4.setLayoutX(750.0D);
        calcEchiprobL4.setLayoutY(427.0D);
        calcEchiprobL4.setPrefHeight(25.0D);
        calcEchiprobL4.setPrefWidth(56.0D);
        calcEchiprobL4.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcEchiprobL4.setTextFill(Color.RED);
        root.getChildren().add(calcEchiprobL4);

        Text textEchiprobL4 = new Text();
        textEchiprobL4.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textEchiprobL4.setX(30);
        textEchiprobL4.setY(445);
        textEchiprobL4.setLayoutX(750.0D);
        textEchiprobL4.setLayoutX(777.0D);
        textEchiprobL4.setText("Criteriul echiprobabilităţii (Laplace)");
        textEchiprobL4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textEchiprobL4);

        calcEchiprobL4.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            double[][] utilityMatrix = new double[r][c];
            utilityMatrix = MatrixUtils.getUtility(matrix, r, c, priorityArray);
            double echiprobL4 = MatrixUtils.getEchiprob(utilityMatrix, r, c);

            TextField displayEchiprobL4 = new TextField("" + echiprobL4);
            displayEchiprobL4.setLayoutX(1075.0D);
            displayEchiprobL4.setLayoutY(427);
            displayEchiprobL4.setPrefWidth(75.0D);
            displayEchiprobL4.setPrefHeight(25.0D);
            displayEchiprobL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayEchiprobL4);
        });
//          ////////////////////////////////////////////////////////////////////Regret L4
        Button calcRegretL4 = new Button();
        calcRegretL4.setText("Calc");
        calcRegretL4.setLayoutX(750.0D);
        calcRegretL4.setLayoutY(453.0D);
        calcRegretL4.setPrefHeight(25.0D);
        calcRegretL4.setPrefWidth(56.0D);
        calcRegretL4.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRegretL4.setTextFill(Color.RED);
        root.getChildren().add(calcRegretL4);

        Text textRegretL4 = new Text();
        textRegretL4.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textRegretL4.setX(30);
        textRegretL4.setY(470);
        textRegretL4.setLayoutX(750.0D);
        textRegretL4.setLayoutX(777.0D);
        textRegretL4.setText("Criteriul regretelor (Savage)");
        textRegretL4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textRegretL4);
        calcRegretL4.setOnAction(event -> {
            readMatrixFromTextFields(r, c, textMatrixArray, matrix);
            priorityParse(c, text_priorityArray, priorityString);
            double[][] utilityMatrix = new double[r][c];
            utilityMatrix = MatrixUtils.getUtility(matrix, r, c, priorityArray);
            double regretL4 = MatrixUtils.getRegret(utilityMatrix, r, c);
            TextField displayRegretL4 = new TextField("" + regretL4);
            displayRegretL4.setLayoutX(1075.0D);
            displayRegretL4.setLayoutY(453);
            displayRegretL4.setPrefWidth(75.0D);
            displayRegretL4.setPrefHeight(25.0D);
            displayRegretL4.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRegretL4);

        });
//        //////////////////////////////////////////////////////////////////Clasa 5 Fuzzy
        Text text4 = new Text();
        text4.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 13));
        text4.setX(30);
        text4.setY(497);
        text4.setLayoutX(1100.0D);
        text4.setLayoutX(720.0D);
        text4.setText("Clasa V Prob. dec. cu logică Fuzzy");
        text4.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(text4);
//        ///////////////////////////////////////////////////////////////Optimist L5
        double exponent = 2.71828;
        Button calcOptimistL5 = new Button();
        calcOptimistL5.setText("Calc");
        calcOptimistL5.setLayoutX(750.0D);
        calcOptimistL5.setLayoutY(503.0D);
        calcOptimistL5.setPrefHeight(25.0D);
        calcOptimistL5.setPrefWidth(56.0D);
        calcOptimistL5.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcOptimistL5.setTextFill(Color.RED);
        root.getChildren().add(calcOptimistL5);

        Text textOptimistL5 = new Text();
        textOptimistL5.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textOptimistL5.setX(30);
        textOptimistL5.setY(520);
        textOptimistL5.setLayoutX(750.0D);
        textOptimistL5.setLayoutX(777.0D);
        textOptimistL5.setText("Criteriul optimist (Maximax)");
        textOptimistL5.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textOptimistL5);

        calcOptimistL5.setOnAction(event -> {
            double[][] finalMatrixBelonging = fuzzyCreate(r, c, textMatrixArray, textProbabilityArray, text_priorityArray,
                    matrix, probabilityArray, priorityArray, alphaArray, priorityString, exponent);
            double optimistL5 = MatrixUtils.getOptimist(finalMatrixBelonging, r, c);
            TextField displayOptimistL5 = new TextField("" + optimistL5);
            displayOptimistL5.setLayoutX(1075.0D);
            displayOptimistL5.setLayoutY(503.0D);
            displayOptimistL5.setPrefWidth(75.0D);
            displayOptimistL5.setPrefHeight(25.0D);
            displayOptimistL5.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayOptimistL5);
        });
//        /////////////////////////////////////////////////////////////////////////////Pesimist L5
        Button calcPesimistL5 = new Button();
        calcPesimistL5.setText("Calc");
        calcPesimistL5.setLayoutX(750.0D);
        calcPesimistL5.setLayoutY(530.0D);
        calcPesimistL5.setPrefHeight(25.0D);
        calcPesimistL5.setPrefWidth(56.0D);
        calcPesimistL5.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcPesimistL5.setTextFill(Color.RED);
        root.getChildren().add(calcPesimistL5);

        Text textPesimistL5 = new Text();
        textPesimistL5.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textPesimistL5.setX(30);
        textPesimistL5.setY(548);
        textPesimistL5.setLayoutX(750.0D);
        textPesimistL5.setLayoutX(777.0D);
        textPesimistL5.setText("Criteriul pesimist (Maximin) ");
        textPesimistL5.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textPesimistL5);

        calcPesimistL5.setOnAction(event -> {
            double[][] finalMatrixBelonging = fuzzyCreate(r, c, textMatrixArray, textProbabilityArray, text_priorityArray,
                    matrix, probabilityArray, priorityArray, alphaArray, priorityString, exponent);
            double pesimistL5 = MatrixUtils.getPessimist(finalMatrixBelonging, r, c);

            TextField displayPesimistL5 = new TextField("" + pesimistL5);
            displayPesimistL5.setLayoutX(1075.0D);
            displayPesimistL5.setLayoutY(530.0D);
            displayPesimistL5.setPrefWidth(75.0D);
            displayPesimistL5.setPrefHeight(25.0D);
            displayPesimistL5.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayPesimistL5);
        });
//        ////////////////////////////////////////////////////////////////////////////Realist L5
        Button calcRealistL5 = new Button();
        calcRealistL5.setText("Calc");
        calcRealistL5.setLayoutX(750.0D);
        calcRealistL5.setLayoutY(557.0D);
        calcRealistL5.setPrefHeight(25.0D);
        calcRealistL5.setPrefWidth(56.0D);
        calcRealistL5.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRealistL5.setTextFill(Color.RED);
        root.getChildren().add(calcRealistL5);

        Text textRealistL5 = new Text();
        textRealistL5.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textRealistL5.setX(30);
        textRealistL5.setY(575);
        textRealistL5.setLayoutX(750.0D);
        textRealistL5.setLayoutX(777.0D);
        textRealistL5.setFill(Color.LIGHTSKYBLUE);
        textRealistL5.setText("Criteriul realismului (Hurwiez)");
        textRealistL5.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textRealistL5);

        TextField alphaX = new TextField("");
        alphaX.setPromptText("alpha");
        alphaX.setLayoutX(1029.0D);
        alphaX.setLayoutY(557.0D);
        alphaX.setPrefWidth(45.0D);
        alphaX.setPrefHeight(25.0D);
        alphaX.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
        root.getChildren().add(alphaX);

        calcRealistL5.setOnAction(event -> {
            double[][] finalMatrixBelonging = fuzzyCreate(r, c, textMatrixArray, textProbabilityArray, text_priorityArray,
                    matrix, probabilityArray, priorityArray, alphaArray, priorityString, exponent);
            double alphaXValue = Double.parseDouble(alphaX.getText());
            double realistL5 = MatrixUtils.getRealist(finalMatrixBelonging, r, c, alphaXValue);

            TextField displayRealistL5 = new TextField("" + realistL5);
            displayRealistL5.setLayoutX(1075.0D);
            displayRealistL5.setLayoutY(557.0D);
            displayRealistL5.setPrefWidth(75.0D);
            displayRealistL5.setPrefHeight(25.0D);
            displayRealistL5.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRealistL5);
        });
//        /////////////////////////////////////////////////////////////////////////////Echiprob L5
        Button calcEchiprobL5 = new Button();
        calcEchiprobL5.setText("Calc");
        calcEchiprobL5.setLayoutX(750.0D);
        calcEchiprobL5.setLayoutY(584.0D);
        calcEchiprobL5.setPrefHeight(25.0D);
        calcEchiprobL5.setPrefWidth(56.0D);
        calcEchiprobL5.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcEchiprobL5.setTextFill(Color.RED);
        root.getChildren().add(calcEchiprobL5);

        Text textEchiprobL5 = new Text();
        textEchiprobL5.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textEchiprobL5.setX(30);
        textEchiprobL5.setY(600);
        textEchiprobL5.setLayoutX(750.0D);
        textEchiprobL5.setLayoutX(777.0D);
        textEchiprobL5.setFill(Color.LIGHTSKYBLUE);
        textEchiprobL5.setText("Criteriul echiprobabilităţii(Laplace)");
        textEchiprobL5.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textEchiprobL5);

        calcEchiprobL5.setOnAction(event -> {
            double[][] finalMatrixBelonging = fuzzyCreate(r, c, textMatrixArray, textProbabilityArray, text_priorityArray,
                    matrix, probabilityArray, priorityArray, alphaArray, priorityString, exponent);
            double echiprobL5 = MatrixUtils.getEchiprob(finalMatrixBelonging, r, c);

            TextField displayEchiprobL5 = new TextField("" + echiprobL5);
            displayEchiprobL5.setLayoutX(1075.0D);
            displayEchiprobL5.setLayoutY(584.0D);
            displayEchiprobL5.setPrefWidth(75.0D);
            displayEchiprobL5.setPrefHeight(25.0D);
            displayEchiprobL5.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayEchiprobL5);
        });
//        //////////////////////////////////////////////////////////////////////////////Regret L5
        Button calcRegretL5 = new Button();
        calcRegretL5.setText("Calc");
        calcRegretL5.setLayoutX(750.0D);
        calcRegretL5.setLayoutY(610.0D);
        calcRegretL5.setPrefHeight(25.0D);
        calcRegretL5.setPrefWidth(56.0D);
        calcRegretL5.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        calcRegretL5.setTextFill(Color.RED);
        root.getChildren().add(calcRegretL5);

        Text textRegretL5 = new Text();
        textRegretL5.setFont(Font.font("verdana", FontPosture.REGULAR, 13));
        textRegretL5.setX(30);
        textRegretL5.setY(625);
        textRegretL5.setLayoutX(750.0D);
        textRegretL5.setLayoutX(777.0D);
        textRegretL5.setFill(Color.LIGHTSKYBLUE);
        textRegretL5.setText("Criteriul regretelor (Savage)");
        textRegretL5.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(textRegretL5);

        calcRegretL5.setOnAction(event -> {
            double[][] finalMatrixBelonging = fuzzyCreate(r, c, textMatrixArray, textProbabilityArray, text_priorityArray,
                    matrix, probabilityArray, priorityArray, alphaArray, priorityString, exponent);
            double regretL5 = MatrixUtils.getRegret(finalMatrixBelonging, r, c);

            TextField displayRegretL5 = new TextField("" + regretL5);
            displayRegretL5.setLayoutX(1075.0D);
            displayRegretL5.setLayoutY(610.0D);
            displayRegretL5.setPrefWidth(75.0D);
            displayRegretL5.setPrefHeight(25.0D);
            displayRegretL5.setStyle("-fx-border-color:  green; -fx-border-radius: 5; -fx-background-color: #2a2a2e; -fx-text-fill: red");
            root.getChildren().add(displayRegretL5);
        });
///////////////////////////////////////////////////////////////////////////////////////Finisarea Logica Algoritmi
        //        ////////////////////////////////////////////////////////////////////////////Probability Gen
        int x = 10;
        int y = 10;
        double correctWidth = 15;
        double correctHeight = -4;
        double width = 45.0D;
        double height = 20.0D;
        rows = r;
        columns = c;
        int xProb = 10;
        int correctWidthProb = 20;
        double widthProb = 45.0D;

        Text probabilityGen = new Text();
        probabilityGen.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 15));
        probabilityGen.setX(120);
        probabilityGen.setY(428);
        probabilityGen.setLayoutX(140.0D);
        probabilityGen.setLayoutX(20);
        probabilityGen.setText("Zecimile probabilităților si altor variabile sunt indicate prin punct.");
        probabilityGen.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(probabilityGen);

        if (true){
            ++this.flag;
            panel2.getChildren().clear();
            for(this.j = 0; this.j < columns; ++this.j) {
                textProbabilityArray[this.j] = new TextField();
                textProbabilityArray[this.j].setLayoutX((xProb * (this.j + 1)) + this.j * widthProb + correctWidthProb);
                textProbabilityArray[this.j].setLayoutY(445.0D);
                textProbabilityArray[this.j].setPrefWidth(widthProb / 1.0D);
                panel2.getChildren().add(textProbabilityArray[this.j]);
            }
        }
        root.getChildren().add(panel2);
//        /////////////////////////////////////////////////////////////////////////////////////Priority Gen
        Text priorityGen = new Text();
        priorityGen.setFont(Font.font("noto-sans", FontWeight.BOLD, FontPosture.REGULAR, 15));
        priorityGen.setX(127);
        priorityGen.setY(509);
        priorityGen.setLayoutX(20.0D);
        priorityGen.setLayoutX(20);
        priorityGen.setText("Prioritatile sunt indicate cu 1 -> Max, 0 -> Min.");
        priorityGen.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(priorityGen);

        if (true) {
            ++this.flag;
            panel3.getChildren().clear();

            for(this.j = 0; this.j < columns; ++this.j) {
                text_priorityArray[this.j] = new TextField();
                text_priorityArray[this.j].setLayoutX((x * (this.j + 1)) + this.j * widthProb + correctWidthProb);
                text_priorityArray[this.j].setLayoutY(525);
                text_priorityArray[this.j].setPrefWidth(widthProb / 1.0D);
                panel2.getChildren().add(text_priorityArray[this.j]);
            }
        }
        root.getChildren().add(panel3);
        ///////////////////////////////////////////////////////////////////////////////////////Gen Matrix
        if (true) {
            ++this.flag;
            panel1.getChildren().clear();
            for (this.i = 0; this.i < rows; ++this.i) {
                for (this.j = 0; this.j < columns; ++this.j) {
                    textMatrixArray[this.i][this.j] = new TextField();
                    textMatrixArray[this.i][this.j].setLayoutX( (x * (this.j + 1)) + this.j * width + correctWidth);
                    textMatrixArray[this.i][this.j].setLayoutY( (y * (this.i + 1)) + this.i * height - correctHeight);
                    textMatrixArray[this.i][this.j].setPrefWidth(width / 1.0D);
                    panel1.getChildren().add(textMatrixArray[this.i][this.j]);
                }

            }
        }
        root.getChildren().add(panel1);
//        ///////////////////////////////////////////////////////////////////////////////Buttons
//        Reset Matrix BTN
        Button resetMatrixBtn = new Button();
        resetMatrixBtn.setText("Reset Matrix");
        resetMatrixBtn.setLayoutX(30.D);
        resetMatrixBtn.setLayoutY(560.0D);
        resetMatrixBtn.setPrefHeight(30.0D);
        resetMatrixBtn.setPrefWidth(100.0D);
        resetMatrixBtn.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        resetMatrixBtn.setTextFill(Color.RED);
        root.getChildren().add(resetMatrixBtn);

        resetMatrixBtn.setOnAction((event ->{
            for(int i = 0; i < r; i ++) {
                for(int j = 0; j < c; j ++) {
                    textMatrixArray[i][j].clear();
                }
            }
            for (int i = 0; i < rows; i ++) {
                for (int j = 0; j < columns ; j++) {
                    System.out.println(matrix[i][j] + " ");
                }
                System.out.println();
            }
        } ));
//      Reset all BTN
        Button resetAll = new Button();
        resetAll.setText("Reset All");
        resetAll.setLayoutX(140.D);
        resetAll.setLayoutY(560.0D);
        resetAll.setPrefHeight(30.0D);
        resetAll.setPrefWidth(100.0D);
        resetAll.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        resetAll.setTextFill(Color.RED);
        root.getChildren().add(resetAll);

        resetAll.setOnAction((event ->{
            for(int i = 0; i < r; i ++) {
                for(int j = 0; j < c; j ++) {
                    textMatrixArray[i][j].clear();
                }
            }
            for (int i = 0; i < rows; i ++) {
                for (int j = 0; j < columns ; j++) {
                    System.out.println(matrix[i][j] + " ");
                }
                System.out.println();
            }
            for(int j = 0; j < c; j ++) {
                textProbabilityArray[j].clear();
            }
            for (int j = 0; j < columns ; j++) {
                System.out.println(probabilityArray + " ");
            }
            for(int j = 0; j < c; j ++) {
                text_priorityArray[j].clear();
            }
            for (int j = 0; j < columns ; j++) {
                System.out.println(priorityArray + " ");
            }
        } ));
//        reset probability
        Button resetProbability = new Button();
        resetProbability.setText("Reset Prob.");
        resetProbability.setLayoutX(30.D);
        resetProbability.setLayoutY(410.0D);
        resetProbability.setPrefHeight(20.0D);
        resetProbability.setPrefWidth(105.0D);
        resetProbability.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        resetProbability.setTextFill(Color.RED);
        root.getChildren().add(resetProbability);

        resetProbability.setOnAction((event ->{
            for(int j = 0; j < c; j ++) {
                textProbabilityArray[j].clear();
            }
            for (int j = 0; j < columns ; j++) {
                System.out.println(probabilityArray + " ");
            }
        } ));
//        Reset priority BTN
        Button resetPriority = new Button();
        resetPriority.setText("Reset Priorități");
        resetPriority.setLayoutX(30.D);
        resetPriority.setLayoutY(490.0D);
        resetPriority.setPrefHeight(20.0D);
        resetPriority.setPrefWidth(115.0D);
        resetPriority.setStyle("-fx-background-color:  #2a2a2e; -fx-border-color: LIGHTSKYBLUE; -fx-border-radius: 5");
        resetPriority.setTextFill(Color.RED);
        root.getChildren().add(resetPriority);

        resetPriority.setOnAction((event ->{
            for(int j = 0; j < c; j ++) {

                text_priorityArray[j].clear();
            }
            for (int j = 0; j < columns ; j++) {
                System.out.println(priorityArray + " ");
            }
        } ));
//        Copyright
        Text copyright = new Text();
        copyright.setFont(Font.font("noto-sans", FontWeight.BOLD, FontPosture.REGULAR, 15));
        copyright.setX(550);
        copyright.setY(640);
        copyright.setLayoutX(20.0D);
        copyright.setLayoutX(20);
        copyright.setText("© Dolință Cristian");
        copyright.setFill(Color.LIGHTSKYBLUE);
        root.getChildren().add(copyright);
//     window parameters
        root.setStyle("-fx-background-color: #2a2a2e;");
        Stage primaryStage = new Stage();
        Scene scene = new Scene(root, 1200.0D, 650.0D);
        primaryStage.setTitle("Generarea Matricei");
        primaryStage.setResizable(true);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    private double[][] fuzzyCreate(int r, int c, TextField[][] textMatrixArray, TextField[] textProbabilityArray,
                                   TextField[] text_priorityArray, double[][] matrix, double[] probabilityArray,
                                   double[] priorityArray, double[] alphaArray, String[] priorityString,
                                   double exponent) {
        double[][] distanceMatrix = new double[r][c];
        double[][] xMatrix = new double[r][c];
        double[][] finalMatrixBelonging = new double[r][c];
        readMatrixFromTextFields(r, c, textMatrixArray, matrix);
        priorityParse(c, text_priorityArray, priorityString);
        parsePonderi(c, textProbabilityArray, probabilityArray);
        distanceMatrix = MatrixUtils.calcGrDepartare(matrix, priorityArray[0], r, c);
        xMatrix = MatrixUtils.calcXMatrix(distanceMatrix, alphaArray, r, c);
        finalMatrixBelonging = MatrixUtils.calcBelogingMatrix(xMatrix, exponent, priorityArray[0], r, c);
        return finalMatrixBelonging;
    }

    private void priorityParse(int c, TextField[] text_priorityArray, String[] priorityString) {
        for (int j = 0; j < c; j++) {
            priorityString[j] = ((text_priorityArray[j])).getText();
        }


        for (int j = 0; j < columns; j++) {
            System.out.println("Prioritatile" + priorityString[j]);
        }
    }

    private void parsePonderi(int c, TextField[] text_t2, double[] ponderiArray) {
        for (int j = 0; j < c; j++) {
            ponderiArray[j] = Double.parseDouble(text_t2[j].getText());
        }
        for (int j = 0; j < columns; j++) {
            System.out.println("Ponderile" + ponderiArray[j]);
        }
    }

    private void readMatrixFromTextFields(int r, int c, TextField[][] textMatrixArray, double[][] matrix) {
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                matrix[i][j] = Double.parseDouble(textMatrixArray[i][j].getText());
            }
        }
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                System.out.println(matrix[i][j] + " ");
            }
            System.out.println();
        }
    }
}